home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-07 | 718 b | 46 lines | [TEXT/R*ch] |
- /***
- *
- * HexDump1.bob - Example program to dump any file in hexidecimal.
- *
- ***/
-
- main ()
- {
- // if (getfile("TEXT"))
- if (getfile())
- ProcessFile();
- else
- print("*** ERROR: Couldn't get file ***\n");
- }
-
-
- HexByte (byte ; str, n)
- {
- str = newstring(2);
- n = (byte >> 4) & 15;
- str[0] = (n <= 9 ? '0' : 'A' - 10) + n;
- n = byte & 15;
- str[1] = (n <= 9 ? '0' : 'A' - 10) + n;
- return str;
- }
-
-
- ProcessFile ( ; c, i, line)
- {
- line = "000000: ";
- i = 0;
-
- while ((c = getc(stdin)) != -1) {
- line += " " + HexByte(c);
- ++i;
- if ((i & 15) == 0) {
- print(line, "\n");
- line = HexByte(i >> 16) + HexByte(i >> 8) +
- HexByte(i) + ": ";
- }
- }
- if (sizeof(line) != 0)
- print(line, "\n");
- print("<END>\n");
- }
-